package com.aaa.service.impl;

import com.aaa.mapper.StudentMapper;
import com.aaa.pojo.Student;
import com.aaa.service.StudentService;
import com.aaa.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentServiceImpl implements StudentService {
    @Autowired
    private StudentMapper studentMapper;

    @Override
    public Result queryAll() {
        List<Student> students = studentMapper.selectAll();
        return new Result(200, "查询所有学生信息", students);
    }

    @Override
    public Result queryById(Integer id) {
        Student byId = studentMapper.findById(2);
        return new Result(200, "根据id查询到的学生信息", byId);
    }

    @Override
    public int insert(Student student) {

        return studentMapper.insert(student);
    }

    @Override
    public int deleteById(Integer id) {
        return studentMapper.deleteById(id);
    }

    @Override
    public Result updateIdInt(Student student) {
        int i = studentMapper.updateIdInt(student);
        if(i>0){
            return new Result(200,"修改成功");
        }else {
            return new Result(500,"修改失败");
        }
    }

}
